#pragma once

#include "messages.hpp"
#include <cstdint>

namespace actor {

struct Uart : rl::Actor<3> {
  using Parent = rl::Actor<3>;
  using Parent::Parent;

  void initialize() override;

private:
  static constexpr int SZ = 4096;

  void on_log_static(message::LogStatic &);
  void on_log_dynamic(message::LogDynamic &);
  void on_commit(message::LogCommit &);

  void do_log(std::string_view);
  void send_next();

  char buff[SZ];
  int next_idx;
  int free_idx;
  bool in_progress;
};

} // namespace actor
